/**
 * 
 */
package MariMonDaily;

import java.util.List;

import com.dukascopy.api.IBar;
import com.dukascopy.api.IHistory;`
import com.dukascopy.api.IOrder;
import com.dukascopy.api.Instrument;
import com.dukascopy.api.JFException;
import com.dukascopy.api.Period;
import com.dukascopy.api.impl.History;

import org.joda.time.DateTime;

/**
 * @author jon
 *
 */
public class TradeChecker {

	/**
	 * 
	 */
	
	private IHistory history;
	
	public TradeChecker() {
		// TODO Auto-generated constructor stub
	}
	
	public boolean AllowedDistancePrevTrade(String strSymbol, int MagicNumber, List<IOrder> orders, Instrument instrument, double DistanceInterTrade) throws JFException{
		
		boolean DistanceLastOpenPrice = true;
		
		double LastOpenPrice = new OrderCounter().LastOpenTradePrice(strSymbol, MagicNumber, orders, instrument);
		
		double bid = history.getLastTick(instrument).getBid();
		
		if (LastOpenPrice > 0){
		    // funky way to get the last tick bid price of the instrument
			if ( bid > LastOpenPrice ){
				if ( (bid - LastOpenPrice) < DistanceInterTrade * instrument.getPipValue() )  {
					DistanceLastOpenPrice = false;
				}
				else{
					if ((LastOpenPrice - bid)  < DistanceInterTrade * instrument.getPipValue() ){
						DistanceLastOpenPrice = false;
					}
				}
			}
		}
		
		return (DistanceLastOpenPrice);
		
	}
	
	
	public boolean CheckTradeAllowedMargin(){
		
		boolean allowed = true;
		
		
		
	}

}
